#include "Head.h"

struct MVER
{
	uint32 signature;
	uint32 size;
	uint32 version;
};

struct MHDR
{
	uint32 signature;
	uint32 size;
	uint32 flag;//1=MFBO 2=NORTHREND
	std::vector<uint32> Offsets;
};

struct MH2O
{
	uint32 signature;
	uint32 size;
	struct MH2O_H
	{
		uint32 ofsInfo; //points to MH2O_I
		uint32 nLayer; //no layer = no informations
		uint32 ofsRender; //64-Bit Mask1 points to MH2O_R
	};
	struct MH2O_I
	{
		uint16 LiquidType;
		uint16 flags;
		float heightLevel1;
		float heightLevel2;
		uint8 xOffset;
		uint8 yOffset;
		uint8 width;
		uint8 height;
		uint32 Mask2;						// points to an array of bits with information about the mask. w*h bits (=h bytes).
		uint32 ofsHeightmapData;	// note that if flags & 1 != 1, this chunk is "ocean" and the information stored
											// at HeightmapData does not correspond to the MH2O_HeightmapData structure.
											// Use heightLevel1 (or 2) for height in this case.
	};
	struct MH2O_D
	{
		std::vector<float> heightMap;
		std::vector<char> transparency;
	};
	struct MH2O_R
	{
		std::vector<char> Render;
	};
};

struct MCNK // --schlumpf_ 17:01, 10 August 2009 (CEST), based on: 03-29-2005 By ObscuR, 11-08-2008 by Tharo
{
		   uint32 signature;
		   uint32 size;
/*0x000*/  uint32 flags;
/*0x004*/  uint32 IndexX;
/*0x008*/  uint32 IndexY;
/*0x00C*/  uint32 nLayers;		//0x0		// maximum 4
/*0x010*/  uint32 nDoodadRefs; //0x0
/*0x014*/  uint32 ofsHeight; //MCVT
/*0x018*/  uint32 ofsNormal; //MCNR
/*0x01C*/  uint32 ofsLayer; //MCLY = 0x0 no layers
/*0x020*/  uint32 ofsRefs; // MCRF = 0x0 look into tex0 & tex1
/*0x024*/  uint32 ofsAlpha; //MCAL = 0x0, no alphas
/*0x028*/  uint32 sizeAlpha; //i said no alphas !!!
/*0x02C*/  uint32 ofsShadow;	//no MCSH			// only with flags&0x1
/*0x030*/  uint32 sizeShadow;//no MCSH!!!
/*0x034*/  uint32 areaid;
/*0x038*/  uint32 nMapObjRefs; //0 cause no objects, look into .obj0
/*0x03C*/  uint32 holes; //if holes are wanted then set the right number in it, client will manage it
/*0x040*/  uint32 unused1;	// It is used to determine which detail doodads to show. Values are an array of two bit unsigned integers, naming the layer. size = 4
/*0x044*/  uint32 unused2;
/*0x048*/  uint32 unused3;
/*0x04C*/  uint32 unused4;
/*0x050*/  uint32 predTex;			//no tex	// 03-29-2005 By ObscuR; TODO: Investigate
/*0x054*/  uint32 noEffectDoodad; //no obj				// 03-29-2005 By ObscuR; TODO: Investigate
/*0x058*/  uint32 ofsSndEmitters; //is there but with size=0
/*0x05C*/  uint32 nSndEmitters;			//no entries	//will be set to 0 in the client if ofsSndEmitters doesn't point to MCSE!
/*0x060*/  uint32 ofsLiquid;//we have mh2o
/*0x064*/  uint32 sizeLiquid;  	//mh2o!!		// 8 when not used; only read if >8.
/*0x068*/  Vec3 position;
/*0x06C*/  
/*0x070*/ 
/*0x074*/  uint32 ofsMCCV; 		//tex0 or tex1		// only with flags&0x40, had UINT32 textureId; in ObscuR's structure.
/*0x078*/  uint32 ofsMCLV; 		//tex0 or tex1		// introduced in Cataclysm
/*0x07C*/  uint32 unused; 			                                // currently unused
/*0x080*/
};
/*
Flag		Meaning
0x1 		MCSH chunk available
0x2 		Impassable?
0x4 		River
0x8 		Ocean 
0x10		Magma
0x20		Slime?
0x40		MCCV chunk available
0x8000		Unknown, but heavily used in TBC.
*/

struct MCVT
{
	uint32 signature;
	uint32 size;
	std::vector<float> height; // 145 heights for the chunk!
};

struct MCSE
{
	uint32 signature;
	uint32 size;
};

struct MFBO
{
	uint32 signature;
	uint32 size;
	// both sizes = 9
	std::vector<short> maximum; 
	std::vector<short> minimum;
};
